perm filename PROB6.PUB[LSP,JRA]1 blob
sn#088018 filedate 1974-02-15 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 .SS(Problems)
C00006 ENDMK
C⊗;
.SS(Problems)
%2I.%* This problem deals with the function, %3value%* in {yonss(P2)}.
1. Show how to extend %3 value%* to handle binary and unary minus.
2. Write a function, %3instiantiate%* which will take two arguments,
one representing a set of variables and values; the other representing
a polynomial. %3instiantiate%* is to return a representation of the
polynomial which would result from substituting the values for the variables.
.SS(The great mothers)
.BEGIN CENTERIT;TABIT3(10,25,36);
.GROUP;
←%2I. The Great Mother of All Functions!!! (⊗→%3tgmoaf%*↔←)
%3
\tgmoaf[x] <= \[atom[x] →\[eq[x ;T] → T;
\\\ eq[x;NIL] → NIL;
\\\ T → TRYAGAINNEXTWEEK];
\\ eq[car[x];QUOTE] → cadr[x];
\\ eq[car[x];CAR] → car[tgmoaf[cadr[x]]];
\\ eq[car[x];CDR] → cdr[tgmoaf[cadr[x]]];
\\ eq[car[x];CONS] → cons[tgmoaf[cadr[x]];tgmoaf[caddr[x]]];
\\ eq[car[x];ATOM] → atom[tgmoaf[cadr[x]]];
\\ eq[car[x];EQ] → eq[tgmoaf[cadr[x]];tgmoaf[caddr[x]]];
\\ T → TRYAGAINNEXTWEEK]
%1
.APART
.GROUP
Evaluate the following:
%21.%3 tgmoaf[T]
%22.%3 tgmoaf[A]
%23.%3 tgmoaf[(CAR(QUOTE(A . B)))]
%24.%3 tgmoaf[(CDR (QUOTE (A B)))]
%25.%3 tgmoaf[(EQ (CAR (QUOTE (A . B)))(QUOTE A))]
%26.%3 tgmoaf[(EQ (CAR (QUOTE (A . B))) A)]
%27.%3 tgmoaf[(ATOM (CAR (QUOTE (A B))))]
.APART
.GROUP
←%2II. The Great Mother of All Functions Revisited!!!(⊗→%3tgmoafr%*↔←)
%3
\tgmoafr[x] <= \[atom[x] →\[eq[x;T] → T;
\\\ eq[x;NIL] → NIL;
\\\ T → TRYAGAINNEXTWEEK];
\\ eq[car[x];QUOTE] → cadr[x];
\\ eq[car[x];CAR] → car[tgmoafr[cadr[x]]];
\\ eq[car[x];CDR] → cdr[tgmoafr[cadr[x]]];
\\ eq[car[x];CONS] → cons[tgmoafr[cadr[x]];tgmoafr[caddr[x]]];
\\ eq[car[x];ATOM] → atom[tgmoafr[cadr[x]]];
\\ eq[car[x];COND] → evcond[cdr[x]];
\\ T → TRYAGAINNEXTWEEK]
.APART
.GROUP
\evcond[x] <=\[tgmoafr[caar[x]] → tgmoafr[cadar[x]];
\\ T → evcond[cdr[x]] ]
.APART
.GROUP
%1
Evaluate the following:
%21.%3 tgmoafr[T]
%22.%3 tgmoafr[(CDR (QUOTE (A B)))]
%23.%3 tgmoafr[(EQ (CAR (QUOTE (A . B))) (QUOTE A))]
%24.%3 tgmoafr[(COND((EQ (CAR (QUOTE (A . B)))(QUOTE A))(QUOTE FOO)))]
%25.%3 tgmoafr[(COND((ATOM (QUOTE (A)))(QUOTE FOO))(T(QUOTE BAZ)))]
.APART
.END